package com.xk.meeting.service;

import com.xk.meeting.dao.UserDao;
import com.xk.meeting.dao.UserDaoImpl;
import com.xk.meeting.entity.User;

public class UserServiceImpl implements UserService{
    private UserDao userDao = new UserDaoImpl();
    @Override
    public int reqUser(User user) {
        return userDao.addUser(user);
    }

    @Override
    public boolean isExist(String phone) {
        return userDao.isExist(phone);
    }

    @Override
    public User login(String username, String password) {
        return userDao.query(username,password);
    }

    @Override
    public User getUserForPhone(String username) {
        return userDao.getUserForPhone(username);
    }

    @Override
    public int updateName(String username, int id) {
        return userDao.updateName(username,id);
    }

    @Override
    public String getPasswordById(int id) {
        return userDao.getPasswordById(id);
    }

    @Override
    public int updatePassword(String id, String newpass) {
        return userDao.updatePassword(id,newpass);
    }

    @Override
    public String getNameById(int id) {
        return userDao.getNameById(id);
    }

    @Override
    public String getStatus(int uid) {
        int num = userDao.getStarusById(uid);
        switch (num){
            case -1 : return "未通过";
            case 0 : return "未审核";
            case 1 : return "以通过";
            default : return "";
        }
    }

    @Override
    public String getStatusStyle(int uid) {
        int num = userDao.getStarusById(uid);
        switch (num){
            case -1 : return "status-refuse";
            case 0 : return "status-notyet";
            case 1 : return "status-pass";
            default : return "";
        }
    }

    @Override
    public int changeStatus(int uid, int status) {
        return userDao.changeStatus(uid,status);
    }

    @Override
    public int getState(int id) {
        return userDao.getState(id);
    }


}
